package main

import "fmt"

func assertInt(i interface{}) {
	r, ok := i.(int)
	if !ok {
		fmt.Println("No int")
	} else {
		fmt.Println("Is int ", r)
	}
}

type I interface{}

func assertType(i interface{}) {
	//now:=i.(type)  不行的只能在switch中使用
	switch i.(type) {
	case int:
		fmt.Println("int")
	case string:
		fmt.Println("string")
	case bool:
		fmt.Println("bool")
	case float64:
		fmt.Println("float64")
	case I:
		fmt.Println("I")
	default:
		fmt.Println("unknown")
	}
}

func main() {
	assertInt(1001)
	assertInt("haha")
	assertType("string")
	assertType("bool")
}
